import Vue from 'vue'
import App from './App'

import HttpRequest from './common/httpRequest'
import HttpApi from './common/httpApi.js'
// import i18n from './common/zh_cn.js'
import Config from './common/config.js'

Vue.config.productionTip = false

const msg = (title, duration = 1500, mask = false, icon = 'none') => {
	//统一提示方便全局修改
	if (Boolean(title) === false) {
		return;
	}
	uni.showToast({
		title,
		duration,
		mask,
		icon
	});
}

Vue.filter('toTime', (time) => {
	var fmt = "YYYY-mm-dd HH:MM"
	var date = new Date(time * 1000);
	let ret;
	let opt = {
		"Y+": date.getFullYear().toString(), // 年
		"m+": (date.getMonth() + 1).toString(), // 月
		"d+": date.getDate().toString(), // 日
		"H+": date.getHours().toString(), // 时
		"M+": date.getMinutes().toString(), // 分
		"S+": date.getSeconds().toString() // 秒
		// 有其他格式化字符需求可以继续添加，必须转化成字符串
	};
	for (let k in opt) {
		ret = new RegExp("(" + k + ")").exec(fmt);
		if (ret) {
			fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
		};
	};
	return fmt;
})

Vue.prototype.$Config = Config
Vue.prototype.$Req = HttpRequest
Vue.prototype.$Url = HttpApi
Vue.prototype.$Api = {msg}

App.mpType = 'app'

const app = new Vue({
    ...App
})
app.$mount()
